﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LeetCodeFly.studyPlan.programming.day02
{
    public static class DayTwo
    {
        public static int HammingWeight(uint n)
        {
            return n.ToString().Where(it => it.ToString() == "1").Count();
        }


        public static int SubtractProductAndSum(int n)
        {
            var b = 1; //积
            var c = 0; //和
            while (n != 0)
            {
                b *= n % 10;
                c += n % 10;
                n /= 10;
            }
            return b - c;
        }
    }
}
